import random

from .celery import app
import time

from libs.send_tx_msg import send_msg
# @app.task
# def send_sms(mobile, code):
#     res=send_msg(mobile,code)
#     if res:
#         return '%s的短信发送成功，验证码是%s'%(mobile,code)
#     else:
#         return '%s的短信发送失败'%mobile
#
#
# # @app.task
# # def send_sms(mobile, code):
# #     time.sleep(2)
# #     print('%s手机号，发送短信成功，验证码是：%s' % (mobile, code))
# #     return True
#
# @app.task
# def sckill_goods(name):
#     # 逻辑是：开启事务---》扣减库存---》生成订单
#     import time
#     time.sleep(6)
#     res = random.choice([100, 102])
#     if res == 100:
#         print('%s被秒杀成功了' % name)
#         return True
#     else:
#         print('%s被秒杀失败了' % name)
#         return False

from registered.models import DetailedList
from .celery import app


@app.task
def update_status(user_id):
    DetailedList.objects.filter(id=user_id).update(status=1)
    return True
